package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tanhua.dubbo.mapper.SettingsMapper;
import com.tanhua.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingsApi{

    @Autowired
    private SettingsMapper settingsMapper;

    /**
     * 根据用户Id获取通知设置
     *
     * @param userId
     * @return
     */
    @Override
    public Settings findById(Long userId) {
        return settingsMapper.selectOne(Wrappers.<Settings>lambdaQuery().eq(Settings::getUserId,userId));
    }

    /**
     * 保存通知设置
     *
     * @param settings
     */
    @Override
    public void save(Settings settings) {
        settingsMapper.insert(settings);
    }

    /**
     * 修改通知设置
     *
     * @param settings
     */
    @Override
    public void update(Settings settings) {
        settingsMapper.updateById(settings);
    }
}
